package zhjh;

import java.awt.image.BufferedImage;
import java.util.BitSet;

public class BAFrame {
	private final int width;
	private final int height;
	private BitSet bs;
	public BAFrame(BufferedImage image){
		width = image.getWidth();
		height = image.getHeight();
		bs = new BitSet(width * height);
		int l = 0;
		for (int r=0; r<height; r++) {
			for (int c=0, nc=width; c<nc; c++) {
				int rgb = image.getRGB(c, r);
				boolean bit = (rgb & 0x00808080) != 0;
				bs.set(l, bit);
				l ++;
			}
		}
	}
	public BitSet getRow(int r){
		return bs.get(r * width, (r + 1) * width);
	}
	public boolean get(int r, int c){
		return getRow(r).get(c);
	}
}
